package com.streambolics.std;

/**
 * An AnchorBuilder that adds all anchors to a single line, separated by pipes.
 * 
 * This is typically used to propose individual items as a menu to the user.
 * 
 * @author Sauron
 * 
 */

public class PipedAnchorList implements AnchorBuilder
{
    private final TextBuilder _Builder;
    private boolean           _Piped = false;

    /**
     * Creates the list.
     * 
     * @param aBuilder
     *            The builder to which the text will be actually appended. It is
     *            expected that the builder is currently able to support
     *            addText(), ie openParagraph() or something equivalent has
     *            already been called.
     */

    public PipedAnchorList(TextBuilder aBuilder)
    {
        _Builder = aBuilder;
    }

    @Override
    public void addAnchor (String aURL, String aText)
    {
        if (_Piped)
        {
            _Builder.addText (" | ");
        }
        _Builder.addAnchor (aURL, aText);
        _Piped = true;
    }

}
